#pragma once
#include <memory>
#include <functional>
#include <sys/epoll.h>
#include "Socket.hpp"
#include "Protocol.hpp"
class Reactor;
using namespace SocketModule;
using handler_t = function<string(string&)>;
class Connection
{
public:
    Connection()
    {}
    void SetEvents(uint32_t events)
    {
        _events = events;
    }
    uint32_t GetEvents()
    {
        return _events;   
    }
    void SetOwner(Reactor* owner)
    {
        _owner = owner;
    }
    Reactor* GetOwner()
    {
        return _owner;
    }
    virtual void Recver() = 0;
    virtual void Sender() = 0;
    virtual int GetFd() = 0;
    void RegisterHandler(handler_t handler)
    {
        _handler = handler;
    }
    handler_t GetHandler()
    {
        return _handler;
    }
private:
    uint32_t _events;
    Reactor* _owner;
    handler_t _handler;
};